package Controler.Eleve;

import java.io.IOException;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;


import JDBC.Eleve_Afficher;
import Model.Eleve;
import Model.Listes;


/**
 * Servlet implementation class Eleve_ChargerController
 */
@WebServlet("/Eleve_ChargerController")
public class Eleve_ChargerController extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public Eleve_ChargerController() {
        super();
        // TODO Auto-generated constructor stub
    }


   
    	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    		// TODO Auto-generated method stub
    		
    		HttpSession session = request.getSession();
    		Listes listes = (Listes) session.getAttribute("listes");
    		
    		if (listes==null)
    		{
    			listes = new Listes();
    		}
    		
    		Eleve_Afficher listeEleve = new Eleve_Afficher();
    		ArrayList<Eleve> mesEleves = listeEleve.afficher();
    		listes.setMesEleves(mesEleves);
    		System.out.println(listes.getMesEleves().size());
    		session.setAttribute("listes", listes);
    		request.getRequestDispatcher("Vues/Eleve/vueGRP1_tableauEl.jsp").forward(request, response);

    		
    		
    	}

    	/**
    	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
    	 */
    	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    		// TODO Auto-generated method stub
    	}

    }
